
%\documentclass[letterpaper,12pt]{article}
%\usepackage[x11names,rgb]{xcolor}
%\usepackage{tikz}
%\usepackage{pgffor}
%\usetikzlibrary{shapes,arrows,trees,snakes,patterns}
%\usetikzlibrary{backgrounds}
%\usepackage{amsmath}
%\oddsidemargin 0in
%\evensidemargin 0in
%\topmargin 0in
%\headheight 0in
%\headsep 0in
%\textheight 9in
%\textwidth 6.5in
%\begin{document}
%\pagestyle{empty}
%\vspace*{\fill}
%\begin{center}

\begin{tikzpicture}[scale=1.0]

\draw[very thin,color=gray,xstep=1, ystep=0.5] (-0.1,-0.1) grid (11, 6);
%1cm spacing for x-axis and 0.5 cm spacing for y-axis
\draw[->] (-0.2,0) -- (11.2, 0) node[right] {$n_p$};
\draw[->] (0,-0.2) -- (0, 6.4) node[above] {seconds};

%Draw the x-axis ticks now
\foreach \pos/\label in {0.5/1, 1.5/2, 2.5/4, 3.5/8, 4.5/16, 5.5/32, 6.5/64, 7.5/128, 8.5/256, 9.5/512, 10.5/1024} {
\draw (\pos,0) -- (\pos,-0.1) (\pos cm, -2.5ex) node [anchor=base,fill=white,inner sep=1pt]  {\scriptsize \label};
}

\newdimen\ysc

\ysc=0.1 cm

%Draw the y-axis ticks now...
\foreach \label in {0, 5,...,60} {
\draw (-2.5ex, \ysc*\label) node [anchor=base,fill=white,inner sep=1pt] {\scriptsize \label};
}

%Draw the table for the numbers.
\foreach \ctry in {-2.5, -2, -1.5, -1.0} {
	\foreach \ctrx in {0, 1, ..., 10} {
		\draw[very thin,color=gray] (\ctrx cm, \ctry cm) rectangle +(1,0.5);
	}
}

%Draw the Legend now..
\draw (-5.5,-1.0) rectangle +(5.5,0.5);
\draw[fill=black] (-0.5,-1.0) rectangle +(0.5,0.5);
\draw (-5, -0.75) node[right] {\scriptsize Construction};

\draw (-5.5,-1.5) rectangle +(5.5,0.5);
\draw[fill=black!75] (-0.5,-1.5) rectangle +(0.5,0.5);
\draw (-5, -1.25) node[right] {\scriptsize Internal Balance};

\draw (-5.5,-2.0) rectangle +(5.5,0.5);
\draw[fill=black!50] (-0.5,-2.0) rectangle +(0.5,0.5);
\draw (-5, -1.75) node[right] {\scriptsize Boundary Balance};

\draw (-5.5,-2.5) rectangle +(5.5,0.5);
\draw[fill=black!20] (-0.5,-2.5) rectangle +(0.5,0.5);
\draw (-5, -2.25) node[right] {\scriptsize Communication for Balance};

\newdimen\mypos

%vala: Construction, valb: Internal Balance
%valc: Boundary Balance vald: Communication for Balance
\foreach \pos/\vala/\valb/\valc/\vald in { 
 0 / 2.3 / 8.7 / 2.8 / 1.8 ,
 1 / 3.0 / 11.8 / 3.4 / 1.5 ,
 2 / 3.9 / 16.6 / 6.4 / 2.5 ,
 3 / 3.0 / 24.6  / 8.4 / 3.3 ,
 4 / 5.6 / 26.0 / 6.6 / 3.4 ,
 5 / 4.6 / 17.1 / 10.7 / 4.2 ,
 6 / 4.8 / 18.6 / 9.1 / 3.8 ,
 7 / 6.2 / 23.1 / 9.7 / 4.7 ,
 8 / 6.4 / 20.3 / 11.0 / 4.6 ,
 9 / 8.4 / 21.8 / 10.1 / 5.8 ,
 10 / 15 / 15 / 11 / 14 
 }
 { 

\mypos=\pos cm

%Filing the table below the plot...
\advance \mypos by 0.5 cm

\draw (\mypos, -0.75 cm) node {\tiny \vala};
\draw (\mypos, -1.25 cm) node {\tiny \valb};
\draw (\mypos, -1.75 cm) node {\tiny \valc};
\draw (\mypos, -2.25 cm) node {\tiny \vald};

%Width of the column=0.6 cm, 
%Leave 0.2 cm gap on either side of the column
\advance \mypos by -0.3 cm

%Construction
\draw[fill=black] (\mypos,0) rectangle +(0.6,\ysc*\vala);
\path (\mypos, \ysc*\vala) coordinate (tmpA);

%Internal Balance
\draw[fill=black!75] (tmpA) rectangle +(0.6,\ysc*\valb);
\path (tmpA) +(0, \ysc*\valb) coordinate (tmpB);

%Boundary Balance
\draw[fill=black!50] (tmpB) rectangle +(0.6,\ysc*\valc);
\path (tmpB) +(0, \ysc*\valc) coordinate (tmpC);

%Communication for Balance
\draw[fill=black!20] (tmpC) rectangle +(0.6,\ysc*\vald);

}

\end{tikzpicture}

%\end{center}
%\vspace*{\fill}
%\end{document}
